﻿namespace Nomo.PathFindingModule
{
    /// <summary>
    /// 欧几里得网格距离计算器。
    /// </summary>
    public sealed class EuclideanGridDistanceCalculator : IGridDistanceCalculator
    {
        double IGridDistanceCalculator.CalculatorDistance(Grid a, Grid b)
        {
            if (a == null)
            {
                throw new System.ArgumentNullException(nameof(a));
            }

            if (b == null)
            {
                throw new System.ArgumentNullException(nameof(b));
            }

            var rowDistance    = a.RowIndex                   - b.RowIndex;
            var columnDistance = a.ColumnIndex                - b.ColumnIndex;
            return System.Math.Sqrt(rowDistance * rowDistance + columnDistance * columnDistance);
        }
    }
}
